home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 016 / fansi115.arc / RAWMODE.MAC < prev    next >
Encoding:
Text File  |  1986-02-06  |  2.4 KB  |  93 lines

  1. ;
  2. ;    This is file: RAWMODE.MAC
  3. ;
  4.     page    60,132
  5.     title    RAWMODE.MAC
  6.     subttl    Routines to manipulate console raw mode.
  7. ;
  8. ;    Written by Mark Hersey
  9. ;    Hersey Micro Consulting, Inc.
  10. ;
  11. ;    This program is public domain.  No copyrights reserved.
  12. ;
  13. ;    The purpose of these subroutines is to allow your program
  14. ;    to use raw console output, which is faster than the
  15. ;    normal (cooked or ASCII) mode.  When the console is in cooked
  16. ;    mode, MS-DOS checks for console input (specifically looking
  17. ;    for Ctrl-C == Ctrl-Break) with every character 
  18. ;    that is written to the screen.  In raw mode, it will not.
  19. ;
  20. ;    You may need to change the procedure names to match
  21. ;    the requirements of your compiler.
  22. ;    You may need to change the segment and group names to match
  23. ;    those used by your compiler.
  24. ;
  25. pgroup    group    prog
  26. dgroup    group    data
  27.  
  28. data    segment    byte public 'data'
  29.         assume    nothing
  30.  
  31. saved_mode    db    ?
  32.  
  33.     assume    nothing
  34. data    ends
  35.  
  36. prog    segment    byte public 'prog'
  37.         assume    cs:pgroup,ds:dgroup
  38. ;
  39. ;    raw_mode - Save old mode and put console device into raw mode.
  40. ;
  41. ;    Inputs:
  42. ;        None    
  43. ;    Outputs:
  44. ;        [saved_mode] has old mode in it.
  45. ;        Console is in raw mode.
  46. ;    Comments:
  47. ;        Call once at the start of your program.
  48. raw_mode    proc    near
  49.         public    raw_mode
  50.     
  51.     mov    ah,044h                ;I/O-Control call for devices.
  52.     mov    al,000h                ;Get device information.
  53.     mov    bx,001h                ;File handle for CON: output.
  54.     int    021h                ;Make MS-DOS call.
  55.     mov    [saved_mode],dl            ;Save old mode.
  56.     mov    ah,044h                ;I/O-Control call for devices.
  57.     mov    al,001h                ;Set device information.
  58.     mov    bx,001h                ;File handle for CON: output.
  59.     xor    dh,dh                ;Must be zero.
  60.     or    dl,020h                ;Set raw mode bit, leave others same.
  61.     int    021h                ;Make MS-DOS call.
  62.     ret
  63.     
  64. raw_mode    endp
  65. ;
  66. ;    old_mode - Save old mode and put console device into raw mode.
  67. ;
  68. ;    Inputs:
  69. ;        [saved_mode] has old mode in it.
  70. ;    Outputs:
  71. ;        Console is set to [saved_mode].
  72. ;    Comments:
  73. ;        Call once at the end of your program.
  74. ;
  75. old_mode    proc    near
  76.         public    old_mode
  77.     
  78.     mov    ah,044h                ;I/O-Control call for devices.
  79.     mov    al,001h                ;Set device information.
  80.     mov    bx,001h                ;File handle for CON: output.
  81.     xor    dh,dh                ;Must be zero.
  82.     mov    dl,[saved_mode]            ;Get old mode.
  83.     int    021h                ;Make MS-DOS call.
  84.     ret
  85.  
  86. old_mode    endp
  87.  
  88.         assume    nothing
  89. prog    ends
  90.  
  91.     end
  92.